Skip to content

fix(pat-tinymce): Add support for image scales as fallback for picture variants. - #1496

Closed
thet wants to merge 1 commit into
masterfrom
tinymce-image-scales
Closed

fix(pat-tinymce): Add support for image scales as fallback for picture variants.#1496
thet wants to merge 1 commit into
masterfrom
tinymce-image-scales

Conversation

@thet

@thet thet commented Aug 19, 2025

Copy link
Copy Markdown
Member

picture variants are a new feature in Plone 6. Migrated sites from Plone 5 have not used that, but still contain the "data-scale" instead of the "data-picturevariant" attributes in TinyMCE edited texts. When opening the image dialog existing pictures have no size variant preselected.
This PR fixes that and falls back to the image scale selection. The fallback is activated when no picture variants are configured e.g. by setting the picture variants field in the imaging controlpanel to "{}".

This is an alternative implementation for: #1493

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds fallback support for Plone 5 image scales in TinyMCE when picture variants are not configured, addressing compatibility issues for sites migrated from Plone 5 to Plone 6.

  • Adds backward compatibility for image scales when picture variants are unavailable
  • Updates image dialog template to conditionally render scale options based on available configuration
  • Modifies link handling logic to support both picture variants and legacy image scales

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/pat/tinymce/tinymce--implementation.js Adds parsing logic for imageScales option as fallback when picture variants are not available
src/pat/tinymce/templates/image.xml Updates template to conditionally render scale options for either picture variants or image scales
src/pat/tinymce/js/links.js Implements fallback logic throughout the image handling workflow to support both picture variants and legacy scales

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread src/pat/tinymce/js/links.js Outdated
Comment thread src/pat/tinymce/js/links.js Outdated
…e variants.

picture variants are a new feature in Plone 6. Migrated sites from Plone
5 have not used that, but still contain the "data-scale" instead of the
"data-picturevariant" attributes in TinyMCE edited texts.
When opening the image dialog existing pictures have no size variant
preselected.
This PR fixes that and falls back to the image scale selection.
The fallback is activated when no picture variants are configured e.g.
by setting the picture variants field in the imaging controlpanel
to "{}".
@thet
thet force-pushed the tinymce-image-scales branch from cd81355 to ed65782 Compare August 19, 2025 13:59
@MrTango

MrTango commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

Wouldn't it be better to fix the content in an upgrade step? I think in collective.exportimport this is implemented, as we use that for university migration. This way the content is updates and we don't need to make things more complicated.

Thought's?

@1letter

1letter commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

I think it is better to fix the content.

@petschki

Copy link
Copy Markdown
Member

I'd also fix the content instead. We've used this module https://github.com/collective/collective.exportimport/blob/main/src/collective/exportimport/fix_html.py a lot and also implemented our own upgrade step to fix plone.app.standardtiles.html content also with this factory.

@thet

thet commented Aug 20, 2025

Copy link
Copy Markdown
Member Author

Yes, thinking about this option.
This needs an plone.app.upgrade step then - there is no such upgrade yet.

@thet
thet marked this pull request as draft September 11, 2025 09:35
@thet thet closed this Sep 19, 2025
@thet

thet commented Sep 19, 2025

Copy link
Copy Markdown
Member Author

I used an upgrade step using collective.exportimport.fix_html

@thet
thet deleted the tinymce-image-scales branch January 13, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants